<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
          
    <body>
        <ui:composition template="template/templateIntern.xhtml"> 
            <ui:define name="pageTitle">                
                <h:outputText value="timeitj - Main" />    
            </ui:define>              
            <ui:define name="bodyContent">                
                                                      
                <div class="projectListings">
                    <h3>Projekte, die Sie verwalten:</h3><h:outputText value="&lt;span&gt;keine&lt;/span&gt;" escape="false" rendered="#{ProjectController.ownedProjectsCount == 0}"/>
                    <h:dataTable id="ownedProjectsTable" class="projectsTable" cellspacing="8px" rendered="#{ProjectController.ownedProjectsCount > 0}" binding="#{ProjectController.dataTable}" value="#{ProjectController.ownedProjects}" var="project">
                        <h:column>
                            <h:form>
                                <h:commandLink action="project" actionListener="#{ProjectController.setProject}">
                                    <h:outputText value="#{project.name}" />
                                </h:commandLink>
                            </h:form>
                        </h:column>    
                        <h:column>
                            <h:outputText value="#{project.description}" />
                        </h:column>
                        <h:column>
                            <h:form>
                                <a4j:commandButton value="Projekt löschen" reRender="ownedProjectsTable" actionListener="#{ProjectController.deleteProject}">
                                    <a4j:actionparam name="index" assignTo="#{ProjectController.affectedRowIndex}"  
                                                     value="#{ProjectController.dataTable.rowIndex}"/>
                                </a4j:commandButton>
                            </h:form>
                        </h:column>
                    </h:dataTable> 
                    <h:form>
                        <p>
                            <h:commandLink action="createProject">
                                <h:outputText value="> Neues Projekt anlegen" />
                            </h:commandLink>
                        </p>
                    </h:form>
                </div>
                
                <div class="projectListings">
                    <h3>Projekte, an denen Sie teilnehmen:</h3><h:outputText value="&lt;span&gt;keine&lt;/span&gt;" escape="false" rendered="#{ParticipanceController.attendedProjectsCount == 0}"/>
                    <h:dataTable id="projectsTable" class="projectsTable" cellspacing="8px" rendered="#{ParticipanceController.attendedProjectsCount > 0}" binding="#{ParticipanceController.dataTable}" value="#{ParticipanceController.projectsByPerson}" var="participance">
                        <h:column>
                            <h:outputText value="#{participance.project.name}" />
                        </h:column>    
                        <h:column>
                            <h:outputText value="#{participance.project.description}" />
                        </h:column>
                        <h:column>
                            <h:form>
                                <a4j:commandButton value="Projekt verlassen" reRender="projectsTable" actionListener="#{ParticipanceController.deleteParticipance}">
                                    <a4j:actionparam name="index" assignTo="#{ParticipanceController.affectedRowIndex}"  
                                                     value="#{ParticipanceController.dataTable.rowIndex}"/>
                                </a4j:commandButton>
                            </h:form>
                        </h:column>
                    </h:dataTable>
                </div>
            </ui:define>
        </ui:composition>
    </body>
</html>
